package com.zillion.web.controller.health;

import com.zillion.common.annotation.Log;
import com.zillion.common.core.controller.BaseController;
import com.zillion.common.core.domain.AjaxResult;
import com.zillion.common.core.page.TableDataInfo;
import com.zillion.common.enums.BusinessType;
import com.zillion.common.utils.poi.ExcelUtil;
import com.zillion.health.domain.HealthPersonInfo;
import com.zillion.health.service.IHealthPersonInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 人员信息Controller
 *
 * @author zillion
 * @date 2025-06-01
 */
@RestController
@RequestMapping("/health/dataReview")
public class HealthPersonInfoController extends BaseController
{
    @Autowired
    private IHealthPersonInfoService healthPersonInfoService;

    /**
     * 查询人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('health:dataReview:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthPersonInfo healthPersonInfo)
    {
        startPage();
        List<HealthPersonInfo> list = healthPersonInfoService.selectHealthPersonInfoList(healthPersonInfo);
        return getDataTable(list);
    }

    /**
     * 导出人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('health:dataReview:export')")
    @Log(title = "人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HealthPersonInfo healthPersonInfo)
    {
        List<HealthPersonInfo> list = healthPersonInfoService.selectHealthPersonInfoList(healthPersonInfo);
        ExcelUtil<HealthPersonInfo> util = new ExcelUtil<HealthPersonInfo>(HealthPersonInfo.class);
        util.exportExcel(response, list, "人员信息数据");
    }

    /**
     * 获取人员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('health:dataReview:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(healthPersonInfoService.selectHealthPersonInfoById(id));
    }

    /**
     * 新增人员信息
     */
    @PreAuthorize("@ss.hasPermi('health:dataReview:add')")
    @Log(title = "人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HealthPersonInfo healthPersonInfo)
    {
        return toAjax(healthPersonInfoService.insertHealthPersonInfo(healthPersonInfo));
    }

    /**
     * 修改人员信息
     */
    @PreAuthorize("@ss.hasPermi('health:dataReview:edit')")
    @Log(title = "人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HealthPersonInfo healthPersonInfo)
    {
        return toAjax(healthPersonInfoService.updateHealthPersonInfo(healthPersonInfo));
    }

    /**
     * 删除人员信息
     */
    @PreAuthorize("@ss.hasPermi('health:dataReview:remove')")
    @Log(title = "人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(healthPersonInfoService.deleteHealthPersonInfoByIds(ids));
    }
}
